package com.tridion.utilities.verifier.analyzer;

import java.io.File;

import com.tridion.utilities.verifier.model.ContentDeliveryInstallation;

public class AnalyzerManager {

    /**
     * Chain containing the used analyzer when looking at a root folder.
     */
    private final Analyzer[] analyzersChain = {new InstallationTypeAnalyzer(), new FoldersAnalyzer(), 
            new JarsAnalyzer(), new VersionAnalyzer()};
    // TODO: make this configurable
    
    /**
     * Runs all defined analyzers and gathers all information into a {@link ContentDeliveryInstallation} object
     * which is at the end returned.
     * 
     * @param rootFolder The folder containing the CD installation
     * @return A {@link ContentDeliveryInstallation} object which contains information 
     * added by our defined {@link Analyzer}s
     */
    public ContentDeliveryInstallation analyze(final File rootFolder) {
        // create a new CD installation
        final ContentDeliveryInstallation cdi = new ContentDeliveryInstallation(rootFolder);
        
        // run all our analyzers
        for (Analyzer analyzer : analyzersChain) {
            analyzer.analyze(cdi);
        }
        
        return cdi;
    }
}
